/**
 * Filename: GALocalizationHandler.js
 * Author: Wasay Abbasi
 * Date Created: 2011-04-20
 * Date Updated: 2011-04-20
*/

exports.GALocalizationHandler = Core.Class.singleton({
    classname: 'GALocalizationHandler',
    initialize: function() {
    	//console.log("----- GALocalizationHandler initialize-----");
    },
    reverseGameLanguage: function() {
    	var lang = Core.Capabilities.getLanguage();
        this.reversed = 1;   
      	if(lang == 'en') {
   	     	Core.Localization.setLanguage('ja');
        }
        else {
	    	Core.Localization.setLanguage('en');
        }
    },
    setGameLanguage: function(language) {
    	this.language = language;
    	Core.Localization.setLanguage(language);
    },
    getLocalizedString: function(key) {
        return Core.Localization.getString(key);
    },
	getCurrentSetLanguage: function() {
    	if(this.language) {
    		return this.language;
    	}
    	var lang = Core.Capabilities.getLanguage();
        if(this.reversed == 1) {
            if(lang == 'en') {
                return 'ja';
            }
            else {
                return 'en';
            }
        }
        else {
            return lang;
        }
    },
	
	getRelativeString: function(stringValue ,replaceValueArray) {
    	for(var i=0;i<replaceValueArray.length ;i++) {
    		stringValue = stringValue.replace("%val"+(i+1) ,replaceValueArray[i]);
    	}
    	return stringValue;
    }
});
